<link rel="stylesheet" type="text/css" href="../addons/jy_weidish_naixue/resource/css/list.css?v=2020090801">
<style>
.fui-fullHigh-item.menu.groupbig {width:4.5rem}
.quick-list .quick-item .info {
    text-align:left;
	padding-left: 0.5rem;
    font-size: 0.65rem;
}
.quick-list .quick-item .info .buyline2 {
   height: 1rem;
}
.quick-list .quick-item .info .buyline2 .price {
    color: #000;
    font-size: 0.8rem;
    line-height: 0.8rem;
    width: 100%;
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    -ms-flex: 1;
    flex: 1;
}
.quick-list .quick-item .info .buyline2 .buy {
    color: #000;
    position: relative;
    z-index: 10;
    height: 1rem;
}
.quick-list .quick-item .info .buyline2 .buy .icon {
    font-size: 0.8rem;
    vertical-align: middle;
}
.quick-list .quick-item .thumb {
    height: 3.6rem;
    width: 3.6rem;
    border: 0;
}
.quick-list .quick-item .thumb img {
    height: 3.6rem;
    width: 3.6rem;
    border: 0;
}
.quick-num .minus,
.quick-num .plus {
    width: 1.25rem;
}
.quick-num .minus {
    color: {{main.syscolor||'#abba11'}};
    border: 1px solid {{main.syscolor||'#abba11'}};
}
.quick-num .minus.del {
    color: #999;
    border: 1px solid #999;
}
.quick-num .plus {
    background: {{main.syscolor||'#abba11'}};
    color: #fff;
    position: relative;
    z-index: 11;
}
.dot2{
	background: {{main.syscolor||'#abba11'}};
    border-radius: 0.5rem;
    color: #fff;
    font-size: 0.6rem;
    height: 0.8rem;
    line-height: 0.8rem;
    margin-left: 0.1rem;
    min-width: 0.8rem;
    padding: 0 0.2rem;
    position: absolute;
    top: 0;
    right: 0.3rem;
    vertical-align: top;
    text-align: center;
    z-index: 11;
}
.fui-footer.quick {
	box-shadow:0 0 4px rgba(0,0,0,0.1);
	-webkit-box-shadow:0 0 4px rgba(0,0,0,0.1);
	-moz-box-shadow:0 0 4px rgba(0,0,0,0.1);
	background:none;
	bottom:3rem;
	width:90%;
	left:5%;
	padding:0;
	border-radius: 1.35rem;
}
.fui-footer.quick .quick-cart {
    width:4rem;background: #fff;color:{{main.syscolor||'#abba11'}};border-top-left-radius: 1.35rem;border-bottom-left-radius: 1.35rem;
}
.fui-footer.quick .quick-info{color:#9e9e9e;position: relative;background: #fff;padding-left:0;border-left: 2px solid #fff;border-right: 0 solid #fff;}
.fui-footer.quick .quick-info .icon{position: absolute;top:-0.5rem;}
.fui-footer.quick .quick-info.action .icon{color:{{main.syscolor||'#abba11'}}}
.fui-footer.quick .quick-submit {
    height:auto;background: {{main.syscolor||'#abba11'}};color:#000;border-top-right-radius: 1.35rem;border-bottom-right-radius: 1.35rem;
}
.jylabel-red-o.active,.jylabel-red-o:focus,.jylabel-red-o:hover,.jylabel-red-o[href]:focus,.jylabel-red-o[href]:hover {
	border: 1px solid {{main.syscolor||'#abba11'}};color:{{main.syscolor||'#abba11'}};
}
.menu .dot {
    background: {{main.syscolor||'#abba11'}};
}
.fixed-title {
	color:{{main.syscolor||'#abba11'}};
}
.tips-yellow {
    background-color: #e9e9d1;
    border-color: #e9e9d1;
	color:{{main.syscolor||'#abba11'}}
}
.popup .popup-body .popup-bottom .closed {
    color: {{main.syscolor||'#abba11'}};
}
.syscolor {color:{{main.syscolor||'#abba11'}}}
.sysbgcolor {background:{{main.syscolor||'#abba11'}}}
</style>
<div class='fui-page fui-page-current' style="background:#fff">
    <div class="fui-content quick" style="margin-bottom:0;padding-bottom:0">
			<div class="fui-cell-group" style="margin-top:0">
				<div class="fui-cell">
					<div class="fui-cell-text">
						<div class="text" style="font-size:0.75rem" onclick="$('#showstores').modal();" ><i class="icon icon-shoucang"></i> {{pagedata.store.title}} <i class="icon icon-more"></i></div>
						<div class="subtitle" style="font-size:0.55rem;padding-top:0.5rem">距离您{{pagedata.store.juli || 2.2}}km</div>
					</div>
					<div class="fui-cell-remark noremark">
					<div ng-if="pagedata.pluginset.no_goodslistsendtype!=1" class="jylabel jylabel-switch-label">
						<span ng-class="{'jylabel-switch':1,'active':pagedata.sendtype==2}" ng-click="pagedata.sendtype=2">自取</span>
						<span ng-class="{'jylabel-switch':1,'active':pagedata.sendtype!=2}" ng-click="pagedata.sendtype=1">外卖</span>
					</div>
					</div>
				</div>
			</div>
			<div ng-if="pagedata.pluginset.no_tips!=1" class="tips tips-yellow">
				<i class="fa fa-bullhorn"></i> {{pagedata.pluginset.tips || '买茶送软包包，分享带新，享新人券！'}}
			</div>
            <div class="fui-fullHigh-group">
                <div ng-class="{'fui-fullHigh-item menu':1,'groupbig':pagedata.pluginset.goodslist_groupbig==1}" style="padding-bottom: 3rem;width:4.5rem">
					<nav ng-repeat="item in pagedata.category" ng-click="pagedata.nowckey=$index;pagedata.params.pcate=item.id;pagedata.get_list(true)" ng-class="{'on':pagedata.nowckey==$index}" style="height:3rem">
						<div ng-class="{'subtitle':1,'syscolor':pagedata.nowckey==$index}" style="line-height:2.3rem">{{item.title || '未命名'}}</div>
						<div ng-show="item.total" class="dot" style="display: block;">{{item.total}}</div>
					</nav>
				</div>
                <div class="fui-fullHigh-item container" style="padding-bottom: 5rem;">
                    <div ng-repeat="item in pagedata.category" ng-if="pagedata.nowckey==$index" class="quick-list">
						<div ng-if="$index==0" id="carousel-container" class="carousel slide" data-role="carousel" data-param-auto="true">
							<div class="carousel-inner" role="listbox" style="height:6rem;border-top-left-radius:1rem;">
								<div ng-class="{'item':1, 'active':$index==0}" ng-repeat="nav in pagedata.pluginset.hdps">
									<a href="{{nav.url}}">
										<img ng-src="{{tomedia(nav.picurl) || '../core/resource/images/banner-1.jpg'}}" style="border-top-left-radius:1rem;display: block; width: 100%; height: 100%;">
									</a>
								</div>
							</div>
							<style>
									.fui-swipe-page .fui-swipe-bullet {background: {background}; opacity: {opacity};}
									.fui-swipe-page .fui-swipe-bullet.active {opacity: 1;}
							</style>
							<div id="carousel-jinyun" class="fui-swipe-page" style="padding: 0 5px; bottom: 1.2rem; ">
								<div class="fui-swipe-bullet" ng-repeat="nav in pagedata.shopset.hdps" ng-class="{'active':$index==0}" data-target="#carousel-container" data-slide-to="{{$index}}"></div>
							</div>
						</div>
						<div class="fui-cell-title" style="font-size:0.75rem;padding-bottom:0">{{item.title || '未命名'}} <i ng-if="$index==0" class="icon icon-good-filling syscolor"></i><img ng-if="$index!=0"  style="height:1rem;width:1rem" src="{{tomedia(item.image) || '../addons/jy_weidish_naixue/resource/images/loadimg.png'}}"/></i></div>
                        <div class="content-empty" ng-show="!pagedata.loading && (!pagedata.goodslist || pagedata.goodslist.length == 0)">
							  <i class="icon jinyunicon icon-cry" style="width: 6rem;margin-bottom: 0.5rem;"></i><br/><p style="color: #999;font-size: .75rem">该分类下没有商品！</p>
						</div>
                        <div id="list">
							    <div ng-class="{'quick-item':1, 'small':pagedata.pluginset.goodslist_small}" ng-repeat="(gkey,g) in pagedata.goodslist">
									<a class="thumb" href="javascript:;" ng-click="pagedata.getgoodsdetail(g.id);" data-nocache="true">
										<img src="{{tomedia(g.image) || '../core/resource/images/nopic.jpg'}}"/>
									</a>
									<div class="info">
										<div class="title bold overflow-h1">{{g.title}}</div>
										<div style="font-size:0.55rem"><span style='color:#999;'>{{g.subtitle || '该商品还没有描述!'}}</span></div>
										<div class="buyline2" style="margin-top:0.5rem">
											<div class="subtitle l-f"><span ng-if="g.active.price" class="syscolor" style='font-size:0.55rem;'>{{g.active.title}}</span>￥<span class="price"><span ng-if="!g.active.price" style="font-weight:bold;font-size:0.8rem;">{{g.price}}</span><span ng-if="g.active.price" style="font-weight:bold;font-size:0.8rem;">{{g.active.price}}</span></span>/{{g.unit || '件'}}</div>
											<div class="buy r-f">
												<div ng-show="g.specs_list.length < 1 && g.total>0" ng-class="{'quick-num':true, 'open':g.carttotal>0}">
													<div ng-click="pagedata.minus(g)" class="minus icon icon-subtract"></div>
													<div class="num" style="color:#999">{{g.carttotal}}</div>
													<div ng-show="g.options.length < 1" ng-click="pagedata.plus(g)" class="plus icon icon-tianjia"></div>
												</div>
												<div ng-show="g.specs_list.length < 1 && g.total==0" class="r-f">
													<div class="jylabel jylabel-switch disabled" style="line-height:0.65rem;">已售馨</div>
												</div>
												<div ng-show="g.specs_list.length > 0" class="r-f">
													<div class="jylabel jylabel-switch active" style="line-height:0.65rem" ng-click="pagedata.showselecttaocan=true;pagedata.g=g;pagedata.nowgkey=gkey;pagedata.nowckey=$index;" >选规格</div>
													<div ng-show="g.carttotal" class="dot" style="display: block;">{{g.carttotal}}</div>
												</div>
											</div>
										</div>
									</div>
								</div>
						</div>
                    </div>
                </div>
            </div>
	</div>
	<div ng-if="pagedata.showselecttaocan" class="popup">
		<div class="popup-body">
			<div class="popup-center">
								<div ng-click="pagedata.showselecttaocan=false" class="closebtn syscolor" style="top:0.2rem;right:0.2rem"><i class="icon jinyunicon icon-close" style="font-size:1rem"></i></div>
								<div class="fui-cell-img c" style="padding:1rem">
									<img style="width:6rem;height:6rem;border-radius: 0.2rem;" ng-src="{{tomedia(pagedata.g.image) || '../core/resource/images/nopic.jpg'}}">
									 <div class="c" style="color:#999;font-size:0.6rem">
										当前: {{pagedata.g.selespename}}
									 </div>
								 </div>
								 <div class="fui-cell-title" style="padding-top:0;font-size:0.7rem;border-bottom: 1px solid #f2f2f2;">
									{{pagedata.g.title}}
									<div class="subtitle">
										{{pagedata.g.subtitle || '该商品还没有描述'}}
									 </div>
								 </div>
								<div class="row margin0" style="padding-bottom:4.8rem">
									<div ng-repeat="(k,spec) in pagedata.g.specs_list" class="option-picker-cell option spec">
										<div class="fui-cell-group" style="margin-top:0">
											<div class="fui-cell-title subtitle" style="color:#999;font-size:0.6rem">{{spec.title}}</div>
											<div class="fui-cell" style="padding-top:0.2rem">
												<div class="fui-cell-info">
													<span ng-repeat="item in spec.items" ng-class="{'jylabels jylabel-red-o':1,'active':pagedata.g.specid[k]==item.id}" style="line-height:0.8rem;padding: 0.1rem 0.6rem;" ng-click="pagedata.g.specid[k]=item.id;pagedata.get_optionsid();">{{item.title}}</span>
												</div>
											</div>
										</div>
									</div>
								</div>
								<div class="fui-navbar" style="background:#f2f2f2;bottom:2rem;box-shadow:0 0 0 rgba(0,0,0,0);height:2.5rem;">
										<div class="fui-cell-group" style="margin-top:0;background:#f2f2f2;">
											<div class="fui-cell" style="padding-top:0.3rem">
												<div class="fui-cell-info">
													<div class="subtitle">￥<span class="price" style="color:#000;font-size:0.8rem;line-height:1.2rem">{{pagedata.g.options.price || 0.00}}</span>/{{pagedata.g.unit||'份'}}</div>
													<div class="subtitle" style="color:#999;font-size:0.6rem">
														{{pagedata.g.selespename}}
													 </div>
												</div>
												<div class="fui-cell-remark noremark">
													<div ng-show="pagedata.g.options.stock>0" class="quick-num open" style="text-align:right;">
														<div ng-click="pagedata.sp_minus()" ng-class="{'minus icon icon-subtract':1,'del':pagedata.g.post[pagedata.g.options.id].num==0}" style="background: none;font-size: 0.8rem;"></div>
														<div class="num" style="color:#000">{{pagedata.taocannum}}</div>
														<div ng-click="pagedata.sp_plus()" class="plus icon icon-tianjia" style="border: 1px solid #fff;font-size: 0.8rem;"></div>
													</div>
													<div ng-show="pagedata.g.options.stock==0"></div>
												</div>
											</div>
										</div>
								</div>
								<div class="fui-navbar c sysbgcolor" style="border-bottom-right-radius: 0.2rem;border-bottom-left-radius: 0.2rem;box-shadow:0 0 0 rgba(0,0,0,0);height:2rem;">
											<a ng-show="pagedata.g.options.stock>0" class="nav-item" style="color: #fff;height:2rem;" href="javascript:;" ng-click="pagedata.sp_tocart();">
												加入购物车
											</a>
											<a ng-show="!pagedata.g.options.stock || pagedata.g.options.stock<=0" class="nav-item" style="color: #fff;height:2rem;" href="javascript:;" ng-click="pagedata.showselecttaocan=false">
												已售馨
											</a>
								</div>
								<div class="clear"></div>
						</div>
			</div>
	</div>
	<div ng-if="pagedata.store.isrest==0" class="fui-footer quick">
		<p style="font-size:16px;color:#fff;margin-top:8px;width:100%;text-align: center;">商家休息中,暂不接单</p>
	</div>
		<!-- 底部菜单 -->
		<div ng-show="pagedata.showcarts" class="popup">
			<div class="popup-body">
			<div class="popup-bottom">
				<div class="fui-cell-group" style="margin-top:0;padding-top:1rem;margin-bottom:3rem">
					<i ng-click="pagedata.showcarts=false" class="closed icon icon-close syscolor" style="font-size:1rem;"></i>
					<div class="fixed-title">
						 <span class="befirst spacing">
												 <span class="icon icon-icon-xiexiantiao" style="color:#eff989"></span>
												 <span class="icon icon-icon-xiexiantiao" style="color:#d5e62a"></span>
												 <span class="icon icon-icon-xiexiantiao" style="color:{{main.syscolor||'#abba11'}}"></span>
						</span> 
						<span class="title-text">{{pagedata.table.title?'-餐桌':''}}菜单</span> 
						<span class="spacing">
												 <span class="icon icon-icon-xiexiantiao" style="color:{{main.syscolor||'#abba11'}}"></span>
												 <span class="icon icon-icon-xiexiantiao" style="color:#d5e62a"></span>
												 <span class="icon icon-icon-xiexiantiao" style="color:#eff989"></span>
						</span>
					</div>
					<div ng-repeat="item in pagedata.carts" ng-if="item.total>0" class="fui-cell">
							<div class="fui-cell-text">
								{{item.title}}<span class="subtitle" ng-if="item.optiontitle">({{item.optiontitle}})</span>
							</div>
							<div class="fui-cell-remark noremark">
								<span class="r-f syscolor" style="margin-right:1rem">￥ {{item.price * item.total}} /{{item.unit ||'件'}}<span style="font-size:0.6rem;color:#999" ng-if="item.weight!='0.00'">（{{item.weight}}kg）</span></span>
							</div>
							<div class="fui-cell-remark noremark">
								<div class="quick-num open">
									<div ng-click="pagedata.minus(item,true)" class="minus icon icon-subtract" style="font-size:0.8rem"></div>
									<div class="num" style="color:#333">{{item.total}}</div>
									<div ng-click="pagedata.plus(item,true)" class="plus icon icon-tianjia" style="font-size:0.8rem"></div>
								</div>
							</div>
					</div>
				</div>
				<div ng-if="pagedata.store.isrest != 0 && pagedata.allnum>0" class="fui-footer quick" style="bottom:0.5rem;">
					<div ng-click="pagedata.showcarts=false" class="quick-cart c">
						<img src="../addons/jy_weidish_naixue/resource/images/cart.png" style="margin-top:-0.5rem;width:2.5rem;height:2.5rem;"></i>
						<div class="dot2" style="display: block;top:-1rem;">{{pagedata.allnum}}</div>
					</div>
					<div class="quick-info" style="">
						<div style="width:100%;color:#000">
							<div style="line-height:1rem;height:1rem">￥<span class="bold" style="font-size:1rem;">{{pagedata.showprice}}</span></div>
							<div ng-if="pagedata.sendtype==1" style="line-height:1rem;height:1rem;color:#9e9e9e;font-size:0.5rem">另需配送费￥<span style="font-weight:400">{{pagedata.myshop.out_pay || '0.00'}}</span></div>
							<div ng-if="pagedata.sendtype!=1" style="line-height:1rem;height:1rem;color:#9e9e9e;font-size:0.5rem">在线下单，门店自取</div>
						</div>
					</div>
					<div class="quick-submit remark" href="javascript:;" ng-click="pagedata.check_buy()" style="margin: 0;color:#fff;">
						选好了
					</div>
				</div>
			</div>
			</div>
		</div>
		<div ng-if="pagedata.allnum>0" class="fui-footer quick">
				<div ng-click="pagedata.showcarts=true" class="quick-cart c">
					<img src="../addons/jy_weidish_naixue/resource/images/cart.png" style="margin-top:-0.5rem;width:2.5rem;height:2.5rem;"></i>
					<div ng-if="pagedata.allnum>0" class="dot2" style="display: block; top:-1rem;">{{pagedata.allnum}}</div>
				</div>
				<div class="quick-info" style="">
					<div style="width:100%;color:#000">
						<div style="line-height:1rem;height:1rem">￥<span class="bold" style="font-size:1rem;">{{pagedata.showprice}}</span></div>
						<div ng-if="pagedata.sendtype==1" style="line-height:1rem;height:1rem;color:#9e9e9e;font-size:0.5rem">另需配送费￥<span style="font-weight:400">{{pagedata.myshop.out_pay || '0.00'}}</span></div>
						<div ng-if="pagedata.sendtype!=1" style="line-height:1rem;height:1rem;color:#9e9e9e;font-size:0.5rem">在线下单，门店自取</div>
					</div>
				</div>
				<div ng-if="pagedata.allnum>0" class="quick-submit remark" href="javascript:;" ng-click="pagedata.check_buy()" style="color:#fff;">
					去结算
				</div>
		</div>
		<div class="mask mask-cart"></div>
</div>
<div id="showstores"  class="modal fade" tabindex="-1" style="z-index:99999;display:none;">
	<div class="modal-dialog" style="width:100%;left:0;bottom:0">
		<div class="modal-bottom">
			<div class="fui-list-group"  id="carrierInfo" style="margin: 0;max-height:22rem;overflow-y:scroll">
					<a class="fui-list"  ng-repeat="item in pagedata.storelist" href="javascript:;" ng-click="pagedata.selectstores($index);pagedata.selectstore = item;">
						<div class="fui-list-media">
							<i class="icon icon-map"></i>
						</div>
						<div class="fui-list-inner">
							<div class="subtitle" >
								<span style="overflow: hidden;display: inline-block;">线下门店</span>
								<span class='realname'>{{item.title}}</span>
								
							</div>
							<div class="text address">地址：<span style="color:red">{{item.pcd.province}}</span>({{item.pcd.district}} {{item.pcd.street}} {{item.address}})</div>
						</div>
						<div class="fui-list-angle">
							<div class="angle"></div>
						</div>
					</a>
			</div>
		</div>
	</div>
</div>
<div ng-include="sys_html('shop/_goodsdetail','','','jy_weishop')"></div>
<div ng-include="sys_html('common/pluginnav',true)"></div>
<script type="text/javascript">
scope.pagedata.nowckey = 0;  //状态标记
scope.pagedata.taocannum=1;
// 百度地图API功能
window.scope.location(function(re){
	re=re?re:{}
	var lat_lng = re.lat_lng?re.lat_lng:{};
	scope.get('jy_weishop/store.index/getlist/limit=8&lat='+lat_lng.lat+'&lng='+lat_lng.lng,function(res){
		console.log('storelist');console.log(res);
		if(res.list){
			scope.pagedata.storelist=res.list;
			if(!scope.pagedata.store.id){
				scope.pagedata.store=res.list[0]
			}
		}
	});
});
scope.pagedata.selectstores=function(index){
	console.log('选择门店'+index);
	if(scope.pagedata.storelist){
		scope.pagedata.store = scope.pagedata.storelist[index];
	}
	$('#showstores').modal('hide');
}
//刷新总数和总价
scope.pagedata.refresh=function(){
	scope.pagedata.showprice=scope.price(scope.pagedata.totalprice);
	scope.$evalAsync();
}
scope.pagedata.get_list=function(isfirst){
		var url='jy_weidish_naixue/goodslist/getlist/'
		if(isfirst){
			if(!scope.pagedata.params){
				scope.pagedata.params={};
			}
			scope.pagedata.goodslist=[];
			scope.pagedata.params.page=1;
			scope.pagedata.loaded=false;
		}else if(scope.pagedata.loaded || scope.pagedata.loading){
			return;
		}
		scope.pagedata.loading=true;
		$('#loading_show').show();
		if(typeof(url)!='object'){
			url=scope.tool.links(url);
		}
		var query=scope.made_query(scope.pagedata.params);
		if(url.query){
			url.query+='&'+query;
		}else{
			url.query=query;
		}
		//console.log('query');console.log(query);
		scope.get(url,function(res){
			//console.log(res);
			scope.pagedata.loading=false;
			$('#loading_show').hide();
			if(res=='none'){
				scope.pagedata.loaded=true;
				return;
			}
			if(!Array.isArray(res)){
				var list=res.list?res.list:[]
			}else{
				var list=res
			}
			if(list.length==0 || (scope.pagedata.psize && list.length<scope.pagedata.psize)){
				scope.pagedata.loaded=true;
			}
			if(!scope.pagedata.goodslist || isfirst){
				scope.pagedata.goodslist=[];
			}
			list.forEach(function(row){
				scope.pagedata.goodslist.push(row);
			});
			scope.pagedata.params.page++;
			scope.$evalAsync();
		});
}
scope.pagedata.get_list(true);
scope.pagedata.scroll_bottom=function(){
	scope.pagedata.get_list();
}
//减少
scope.pagedata.minus=function(g,iscart){
	if(iscart){
		g.carttotal=g.total
		g.cartid=g.id
		g.id=g.goodsid
	}
	if(g.carttotal<=0){
		return false;
	}
	scope.post_json('jy_weishop/member.cart/minus/',{'getlist':true,'id':g.cartid},function(res){
			g.carttotal--;
			if(iscart){
				g.total--
				for (j = 0; j < scope.pagedata.goodslist.length; j++) {
						if(scope.pagedata.goodslist[j].id==g.id){
							scope.pagedata.goodslist[j].carttotal=g.total
							if(g.optionid && scope.pagedata.goodslist[j].post){
								if(!scope.pagedata.goodslist[j].post[g.optionid]){
									scope.pagedata.goodslist[j].post[g.optionid]={'num':g.total}
								}
								scope.pagedata.goodslist[j].post[g.optionid].num--;
							}
						}
				}
				for (var i = 0; i < scope.pagedata.category.length; i++) {
						if(scope.pagedata.category[i].id==g.pcate){
							scope.pagedata.category[i].total--
						}
				}
			}else{
				scope.pagedata.category[scope.pagedata.nowckey].total--
			}
			scope.pagedata.carts=res.list
			scope.pagedata.allnum--
			scope.pagedata.totalprice-=g.price*1
			scope.pagedata.refresh();
			
	});
}
//增加
scope.pagedata.plus=function(g,iscart){
	if(iscart){
		g.carttotal=g.total
		g.id=g.goodsid
		if(g.optionid>0){
			if(g.carttotal>=g.options.stock){
				scope.message('不能再添加了，已超过库存！','error');
				return false;
			}
		}else{
			if(g.carttotal>=g.goodstotal){
				scope.message('不能再添加了，已超过库存！','error');
				return false;
			}
		}
	}else{
		g.optionid=0;
		if(g.carttotal>=g.total){
			scope.message('不能再添加了，已超过库存！','error');
			return false;
		}
	}	
	scope.post_json('jy_weishop/member.cart/addtocart/',{'getlist':true,'goodsid':g.id,'optionid':g.optionid},function(res){
			g.carttotal++;
			if(iscart){
				g.total++
				var category=scope.pagedata.category
				for (j = 0; j < scope.pagedata.goodslist.length; j++) {
						if(scope.pagedata.goodslist[j].id==g.id){
							scope.pagedata.goodslist[j].carttotal=g.total
							if(g.optionid && scope.pagedata.goodslist[j].post){
								if(!scope.pagedata.goodslist[j].post[g.optionid]){
									scope.pagedata.goodslist[j].post[g.optionid]={'num':g.total}
								}
								scope.pagedata.goodslist[j].post[g.optionid].num++;
							}
						}
				}
				for (var i = 0; i < scope.pagedata.category.length; i++) {
						if(scope.pagedata.category[i].id==g.pcate){
							scope.pagedata.category[i].total++
						}
				}
			}else{
				scope.pagedata.category[scope.pagedata.nowckey].total++
			}
			if(res!='success'){
				g.cartid=res.id;
				scope.pagedata.carts=res.list
			}
			scope.pagedata.allnum++
			scope.pagedata.totalprice+=g.price*1
			scope.pagedata.refresh();
	});
}
//减少
scope.pagedata.sp_minus=function(){
	if(scope.pagedata.taocannum<=1){
		return false;
	}
	scope.pagedata.taocannum --;
	scope.$evalAsync();
}
//增加
scope.pagedata.sp_plus=function(){
	scope.pagedata.taocannum ++;
	scope.$evalAsync();
}
scope.pagedata.sp_tocart=function(){
	var g =scope.pagedata.g;
	if(g.carttotal>=g.options.stock){
		scope.message('不能再添加了，已超过库存！','error');
		return false;
	}
	scope.pagedata.showselecttaocan=false
	scope.post_json('jy_weishop/member.cart/addtocart/',{'getlist':true,'goodsid':g.id,'optionid':g.options.id,'num':scope.pagedata.taocannum},function(res){
			g.carttotal=g.carttotal*1+parseInt(scope.pagedata.taocannum);
			g.post[g.options.id].num=g.post[g.options.id].num*1+parseInt(scope.pagedata.taocannum);
			if(res!='success'){
				g.cartid=res.id;
				scope.pagedata.carts=res.list
			}
			scope.pagedata.category[scope.pagedata.nowckey].total=scope.pagedata.category[scope.pagedata.nowckey].total*1+parseInt(scope.pagedata.taocannum)
			scope.pagedata.goodslist[scope.pagedata.nowgkey]=g
			scope.pagedata.allnum=scope.pagedata.allnum*1+parseInt(scope.pagedata.taocannum)
			scope.pagedata.totalprice+=g.options.price*1
			scope.pagedata.refresh();
	});
}
//选择
scope.pagedata.get_optionsid=function(){
	var specid = scope.pagedata.g.specid;
	specid = specid.join('_');
	scope.pagedata.taocannum=1;
	scope.post_json('jy_weishop/goods.detail/get_optionsid/',{'goodsid':scope.pagedata.g.id,'specid':specid,'isdish':1,'storeid':scope.pagedata.store.id},function(res){
			var optionsid=res.options.id;
			scope.pagedata.g.options=res.options;
			scope.pagedata.g.selespename=res.selespename;
			if(res.cartid){
				scope.pagedata.g.cartid=res.cartid;
			}
			if(!scope.pagedata.g.post[optionsid]){
				scope.pagedata.g.post[optionsid]={}
				scope.pagedata.g.post[optionsid]={
					'num':scope.pagedata.g.post[optionsid].num?scope.pagedata.g.post[optionsid].num:res.carttotal,
					'title':res.selespename,
				}
			}
			
			scope.$evalAsync();
	});
}
scope.pagedata.refresh();
 $('.plus').on('click', function () {
	var cart = $('.quick-cart');
        var imgtodrag = $(this).parent('.quick-item').find("img").eq(0);
        if (imgtodrag) {
            var imgclone = imgtodrag.clone()
                .offset({
                top: imgtodrag.offset().top,
                left: imgtodrag.offset().left
            })
                .css({
                'opacity': '0.5',
                    'position': 'absolute',
                    'height': '2rem',
                    'width': '2rem',
                    'z-index': '100'
            })
                .appendTo($('body'))
                .animate({
                'top': cart.offset().top + 10,
                    'left': cart.offset().left + 10,
                    'width': 75,
                    'height': 75
            }, 1000, 'easeInOutExpo');
            
            imgclone.animate({
                'width': 0,
                    'height': 0
            }, function () {
                $(this).detach()
            });
        }
});
require(['bootstrap', 'hammer'], function($, Hammer){
		$('#carousel-container').carousel();
		var mc = new Hammer($('#carousel-container').get(0));
		mc.on("panleft", function(ev) {
			$('#carousel-container').carousel('next');
		});
		mc.on("panright", function(ev) {
			$('#carousel-container').carousel('prev');
		});
});
scope.pagedata.check_buy=function(){
	scope.get('jy_weishop/member.cart/check_buy/is_dish=1&storeid='+scope.pagedata.store.id+'&sendtype='+scope.pagedata.sendtype,function(res){});
}
</script>